﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using BSU.Math.Geometry;

namespace BSU.GraduateWork.Data.Model
{
    [Serializable]
    [Table(Name = "SolutionPoints")]
    public class Point:IEntity<int>
    {
        [Column(Name = "id", DbType = "Int IDENTITY", IsPrimaryKey = true, IsDbGenerated = true,
            CanBeNull = false, AutoSync = AutoSync.OnInsert, UpdateCheck = UpdateCheck.Never)]
        public int Id { get; set; }

        [Column(Name = "SolutionId", DbType = "Int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        internal int SolutionId;

        private EntityRef<Solution> _Solution;

        [Association(Storage = "_Solution", ThisKey = "SolutionId")]
        public Solution Solution
        {
            get { return _Solution.Entity; }
            set {_Solution.Entity = value; }
        }

        [Column(Name = "X", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double X { get; set; }

        [Column(Name = "Y", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double Y { get; set; }

        [Column(Name = "Z", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double Z { get; set; }

        [Column(Name = "U", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double U { get; set; }

        [Column(Name = "IsBoundary", DbType = "Bit", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public bool IsBoundary { get; set; }

        public Point()
        {
            Id = -1;
        }
    }
}
